
const Constant = require("./constant.js");

// 钱包app包名
const orangeAppPckageName = "com.orange.orangemoneyafrique";

// 打开 orange app
const openOrangeApp = () => {
    let pckName = orangeAppPckageName;//app.getPackageName("MoMo");
    console.log(Constant.UI_SDK_VERSION + "打开: OrangePay App: ", pckName);

    // com.orange.orangemoneyafrique
    app.launchPackage(pckName)

    console.log(Constant.UI_SDK_VERSION + "等待10秒");
    sleep(10 * 1000);
}

// 退出 orange app
const closeOrangeApp = () => {
    let pckName = orangeAppPckageName;//app.getPackageName("Orange");
    //强制停止 com.orange.orangemoneyafrique
    console.log(Constant.UI_SDK_VERSION + "强制停止 orange app: ", pckName);

    app.openAppSetting(pckName);
    text(app.getAppName(pckName)).waitFor();
    sleep(500);
    click("强行停止")
    console.log(Constant.UI_SDK_VERSION + app.getAppName(pckName) + "应用已被关闭");
    sleep(2 * 1000);
    click("确定");
    sleep(2 * 1000);
    back();
    sleep(5 * 1000);
}

module.exports = {
    momoAppPckageName: orangeAppPckageName,
    openOrangeApp: openOrangeApp,
    closeOrangeApp: closeOrangeApp
};